package com.fowo.api.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.sys.entity.SysDepartment;
import com.fowo.api.sys.model.SysDepartmentSearchParamPo;
import com.fowo.api.sys.model.SysDepartmentVo;
import com.fowo.api.sys.model.SysDeptUserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SysDepartmentMapper extends BaseMapper<SysDepartment> {
    List<SysDepartmentVo> search(@Param("search") SysDepartmentSearchParamPo search);
    List<SysDeptUserVo> searchUser(@Param("search") SysDepartmentSearchParamPo search);
    Page<SysDepartmentVo> pageSearch(@Param("page") Page page, @Param("search") SysDepartmentSearchParamPo search);

    int countParentIdAndName(@Param("parentId") Long parentId, @Param("name") String name);

    List<Long> getDepartmentIdsByUserId(@Param("userId") Long userId);
    List<Long> getUserIdsByDepartmentId(@Param("departmentId") Long departmentId);
    Integer countUserInDepartment(@Param("departmentId") Long departmentId);

    void deleteByUserId(@Param("userId") Long userId);

    int insertUserDepartment(@Param("userId") Long userId, @Param("departmentId") Long departmentId);

    Long getIdByName(String name);

    String getNameById(Long id);
}
